/*
 * intnumberobject.cpp
 *
 *  Created on: Oct 30, 2009
 *      Author: Silviu Caragea
 */

#include "includes/booleanobject.h"

namespace templatipus {
//constructor && destructor

TBooleanObject::TBooleanObject() :TemplateObject(),internalValue(0)
{

}

TBooleanObject::TBooleanObject(const TemplateObject &other) :TemplateObject(other),
	internalValue(other) {

}

TBooleanObject::TBooleanObject(const tbool &rhs) :TemplateObject(rhs),
	internalValue(rhs) {

}

TBooleanObject::TBooleanObject(const int8 &rhs) :TemplateObject(rhs),
	internalValue(rhs) {

}

TBooleanObject::TBooleanObject(const int16 &rhs) :TemplateObject(rhs),
	internalValue(rhs) {

}

TBooleanObject::TBooleanObject(const int32 &rhs) :TemplateObject(rhs),
	internalValue(rhs) {

}

TBooleanObject::TBooleanObject(const int64 &rhs) :TemplateObject(rhs),
	internalValue(rhs) {

}

TBooleanObject::TBooleanObject(const float32 &rhs) :TemplateObject(rhs),
	internalValue(rhs) {

}

TBooleanObject::TBooleanObject(const float64 &rhs) :TemplateObject(rhs),
	internalValue(rhs) {

}

TBooleanObject::TBooleanObject(const std::wstring& rhs):TemplateObject(rhs)
{
	int64 value;
	swscanf(rhs.c_str(), WPRINTF_INT64_MODIFIER, &value);
	this->internalValue = (tbool) value;
}

TBooleanObject::TBooleanObject(const std::string& rhs):TemplateObject(rhs)
{
	int64 value;
	sscanf(rhs.c_str(), PRINTF_INT64_MODIFIER, &value);
	this->internalValue = (tbool) value;
}

TBooleanObject::TBooleanObject(const unicodePtr rhs):TemplateObject(rhs)
{
	int64 value;
	swscanf(rhs, WPRINTF_INT64_MODIFIER, &value);
	this->internalValue = (tbool) value;
}

TBooleanObject::TBooleanObject(const utf8Ptr rhs) :TemplateObject(rhs)
{
	int64 value;
	sscanf(rhs, PRINTF_INT64_MODIFIER, &value);
	this->internalValue = (tbool) value;
}

TBooleanObject::~TBooleanObject() {

}

//assigning values

TemplateObject& TBooleanObject::operator=(const TemplateObject &other) {
	this->internalValue = other;
	return *this;
}

TemplateObject& TBooleanObject::operator=(const int8 &other) {
	this->internalValue = other;
	return *this;
}

TemplateObject& TBooleanObject::operator=(const int16 &other) {
	this->internalValue = other;
	return *this;
}

TemplateObject& TBooleanObject::operator=(const int32 &other) {
	this->internalValue = other;
	return *this;
}

TemplateObject& TBooleanObject::operator=(const int64 &other) {
	this->internalValue = other;
	return *this;
}

TemplateObject& TBooleanObject::operator=(const float32 &other) {
	this->internalValue = other;
	return *this;
}

TemplateObject& TBooleanObject::operator=(const float64 &other) {
	this->internalValue = other;
	return *this;
}

TemplateObject& TBooleanObject::operator=(const std::wstring& other) {
	int64 value;
	swscanf(other.c_str(), WPRINTF_INT64_MODIFIER, &value);
	this->internalValue = (tbool) value;
	return *this;
}

TemplateObject& TBooleanObject::operator=(const std::string& other) {
	int64 value;
	sscanf(other.c_str(), PRINTF_INT64_MODIFIER, &value);
	this->internalValue = (tbool) value;
	return *this;
}

TemplateObject& TBooleanObject::operator=(const utf8Ptr other) {
	int64 value;
	sscanf(other, PRINTF_INT64_MODIFIER, &value);
	this->internalValue = (tbool) value;
	return *this;
}

TemplateObject& TBooleanObject::operator=(const unicodePtr other) {
	int64 value;
	swscanf(other, WPRINTF_INT64_MODIFIER, &value);
	this->internalValue = (tbool) value;
	return *this;
}

//comparison

tbool TBooleanObject::operator ==(const TemplateObject &other) const {
	return (this->internalValue == (tbool) other);
}

tbool TBooleanObject::operator !=(const TemplateObject &other) const {
	return (this->internalValue != (tbool) other);
}

tbool TBooleanObject::operator &&(const TemplateObject &other) const {
	return (this->internalValue && (tbool)other);
}

tbool TBooleanObject::operator ||(const TemplateObject &other) const {
	return (this->internalValue || (tbool) other);
}

//String stuff


TBooleanObject::operator std::string() const {
	if(this->internalValue)
		return std::string("true");

	return std::string("false");
}

TBooleanObject::operator std::wstring() const {
	if(this->internalValue)
		return std::wstring(L"true");

	return std::wstring(L"false");
}

//Conversion operators

TBooleanObject::operator tbool() const {
	return this->internalValue;
}

TBooleanObject::operator int8() const {
	return (int8) this->internalValue;
}

TBooleanObject::operator uint8() const {
	return (uint8) this->internalValue;
}

TBooleanObject::operator int16() const {
	return (int16) this->internalValue;
}

TBooleanObject::operator uint16() const {
	return (uint16) this->internalValue;
}

TBooleanObject::operator int32() const {
	return (int32) this->internalValue;
}

TBooleanObject::operator uint32() const {
	return (uint32) this->internalValue;
}

TBooleanObject::operator int64() const {
	return (int64) this->internalValue;
}

TBooleanObject::operator uint64() const {
	return (uint64) this->internalValue;
}

TBooleanObject::operator float32() const {
	return (float32) this->internalValue;
}

TBooleanObject::operator float64() const {
	return (float64) this->internalValue;
}

}
